home *** CD-ROM | disk | FTP | other *** search
- Path: Starbase.NeoSoft.COM!not-for-mail
- From: timd@Starbase.NeoSoft.COM (TimD)
- Newsgroups: comp.lang.c++
- Subject: Re: templates & declaration of instances...
- Date: 14 Feb 1996 09:47:13 -0600
- Organization: NeoSoft, Inc. +1 713 968 5800
- Message-ID: <4ft061$631@Starbase.NeoSoft.COM>
- References: <4fqf2t$lg0@Starbase.NeoSoft.COM>
- NNTP-Posting-Host: starbase.neosoft.com
-
- In article <4fqf2t$lg0@Starbase.NeoSoft.COM>,
- TimD <timd@Starbase.NeoSoft.COM> wrote:
- >I recently ran into a problem with forward definitions of
- >template instances. [...]
- >
- > // other.h
- > class some_class;
- > class some_other_class
- > {
- > ...
- > void some_func(some_class *ptr);
- > ...
- > };
- >
- >and in the body, I can include the definition of
- >some_class. But, if some class is an instance of
- >a template, how do I do it?
- >
- >I tried the following, and, not surprisingly, it didn't work:
- >
- > // other.cc
- >
- > #include "parameter_class.h"
- > #include "template_class.h"
- >
- > typedef some_template_class<some_parameter_class> some_class;
- >
- > ...
- > void some_other_class::some_func(some_class *ptr)
- > {
- > ...
- > }
- > ...
-
- Okay...someone suggested
-
- class some_class : public some_template_class<some_parameter_class>
-
- which would have worked in some classes, but not this one. This is
- because the template class has calls that return ptrs to other
- instances of the same class:
-
- template <class C> class some_template_class
- {
- ...
- some_template_class<C> *return_ptr_to_class();
- ...
- }
-
- So, now, the following code does not work:
-
- some_class a;
- some_class *b;
-
- b = a.return_ptr_to_class();
-
- That's something I wish were differeent about c++...it should be
- required to define an explicit class or function that is an
- instance of a template...like Ada's Generics:
-
- class some_class = some_template_class<some_parameter_class>;
-
- Why, oh, why did they make it so complicated? :)
-
- -t
-